import axios from 'axios';

async function getQrCodeByOpenId(openId: string) {
  const baseUrl = process.env.API_BASE_URL;
  try {
    const response = await axios.get(`${baseUrl}/api/wxweb/getQrCodeByOpenId`, {
      params: {
        openid: openId
      }
    });
    return Response.json(response.data);
  } catch (error) {
    console.error('Error during HTTP request:', (error as Error).message);
    return null; // 或者根据需要处理错误
  }
}


export async function GET(request: Request) {
  const { searchParams } = new URL(request.url)
  const openId = searchParams.get('openid') || 'defaultOpenId';
  return getQrCodeByOpenId(openId);
}